import { defineStore } from 'pinia';
import axios from 'axios';
export const mainStore = defineStore('main', {
    state: () => {
        return {
            Robot: [],
            NaturalGasProcessing: {
                shunshiliuliang: 0,
            },
            NaturalGasTransfer: {
                shunshiliuliang: 0,
            },
            produce: {
                jihualiang: 0,
                wanchengliang: 0
            },
            fcg: {
                A: 0,
                B: 0,
                C: 0,
                Aplus: 0,
                Bplus: 0,
                Cplus: 0
            },
            ProblemReporting: [
                { value: 0, name: "整改中" },
                { value: 0, name: "已整改" },
                { value: 0, name: "待整改" }
            ],
            color: [],
            inspectionTask: {
                yiwancheng: 0,
                weiwancheng: 0
            },
            time: 0,
        }
    },
    getters: {},
    actions: {
        async getMockData() {
            let result = await axios.get('./MockData.json');
            this.Robot = result.data.MockData.Robot;
            this.produce = result.data.MockData.produce;
            this.fcg = result.data.MockData.fcg;
            this.ProblemReporting = result.data.MockData.ProblemReporting;
            this.color = result.data.MockData.color;
            this.inspectionTask = result.data.MockData.inspectionTask;
            this.time = result.data.MockData.time;
        },
        async getInstantaneousFlowRate() {
            let result = await axios.post('http://10.59.30.132:8001/api/TRQ/QueryShunShi');
            this.NaturalGasProcessing.shunshiliuliang = result.data.天然气处理瞬时
            this.NaturalGasTransfer.shunshiliuliang = result.data.天然气转输瞬时
            setInterval(async () => {
                let result = await axios.post('http://10.59.30.132:8001/api/TRQ/QueryShunShi');
                this.NaturalGasProcessing.shunshiliuliang = result.data.天然气处理瞬时
                this.NaturalGasTransfer.shunshiliuliang = result.data.天然气转输瞬时
            },10000)
        }
    }
})